#!/sbin/openrc-run

depend() {
    need localmount
    after consolekit
    after bootmisc
    use logger
    provide usb-access-control
    provide usbguard
}

start_pre() {
    ebegin "Pre-start security checks for usbguard"
    checkpath --directory --owner root:root /etc/usbguard/
    checkpath --file --owner root:root --mode 0600 /etc/usbguard/usbguard-daemon.conf /etc/usbguard/rules.conf
    eend $?
}

start() {
    ebegin "Starting usbguard daemon"
    start-stop-daemon --start --pidfile /var/run/usbguard.pid --exec /usr/sbin/usbguard-daemon -- -f -s -K $APPEND
    eend $?
}

stop() {
    ebegin "Stopping usbguard daemon" 
    start-stop-daemon --stop --pidfile /var/run/usbguard.pid --exec /usr/sbin/usbguard-daemon -- -f -s -K $APPEND
    eend $?
}
